package de.openlaboratory.elib.model.system;

import java.io.Serializable;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;

public class User implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/** identifier field */
	private Long id;

	/** nullable persistent field */
	private String userName;

	/** nullable persistent field */
	private String userPassword;

	/** nullable persistent field */
	private String userFirstName;

	/** nullable persistent field */
	private String userLastName;

	/** nullable persistent field */
	private String userEmail;

	/** nullable persistent field */
	private Date creationDate;

	/** nullable persistent field */
	private Double createdBy;

	/** nullable persistent field */
	private Date modificationDate;

	/** nullable persistent field */
	private Double modifiedBy;

	/** nullable persistent field */
	private Date deleteDate;

	/** nullable persistent field */
	private Double deletedBy;

	/** persistent field */
	private Set properties;

	/** full constructor */
	public User(String userName, String userPassword, String userFirstName, String userLastName, Date creationDate,
			Double createdBy, Date modificationDate, Double modifiedBy, Date deleteDate, Double deletedBy,
			Set properties)
	{
		this.userName = userName;
		this.userPassword = userPassword;
		this.userFirstName = userFirstName;
		this.userLastName = userLastName;
		this.creationDate = creationDate;
		this.createdBy = createdBy;
		this.modificationDate = modificationDate;
		this.modifiedBy = modifiedBy;
		this.deleteDate = deleteDate;
		this.deletedBy = deletedBy;
		this.properties = properties;
	}

	/** default constructor */
	public User()
	{
	}

	/** minimal constructor */
	public User(Set properties)
	{
		this.properties = properties;
	}

	public Long getId()
	{
		return this.id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public String getUserName()
	{
		return this.userName;
	}

	public void setUserName(String userName)
	{
		this.userName = userName;
	}

	public String getUserPassword()
	{
		return this.userPassword;
	}

	public void setUserPassword(String userPassword)
	{
		this.userPassword = userPassword;
	}

	public String getUserFirstName()
	{
		return this.userFirstName;
	}

	public void setUserFirstName(String userFirstName)
	{
		this.userFirstName = userFirstName;
	}

	public String getUserLastName()
	{
		return this.userLastName;
	}

	public void setUserLastName(String userLastName)
	{
		this.userLastName = userLastName;
	}

	public Date getCreationDate()
	{
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate)
	{
		this.creationDate = creationDate;
	}

	public Double getCreatedBy()
	{
		return this.createdBy;
	}

	public void setCreatedBy(Double createdBy)
	{
		this.createdBy = createdBy;
	}

	public Date getModificationDate()
	{
		return this.modificationDate;
	}

	public void setModificationDate(Date modificationDate)
	{
		this.modificationDate = modificationDate;
	}

	public Double getModifiedBy()
	{
		return this.modifiedBy;
	}

	public void setModifiedBy(Double modifiedBy)
	{
		this.modifiedBy = modifiedBy;
	}

	public Date getDeleteDate()
	{
		return this.deleteDate;
	}

	public void setDeleteDate(Date deleteDate)
	{
		this.deleteDate = deleteDate;
	}

	public Double getDeletedBy()
	{
		return this.deletedBy;
	}

	public void setDeletedBy(Double deletedBy)
	{
		this.deletedBy = deletedBy;
	}

	public Set getProperties()
	{
		return this.properties;
	}

	public void setProperty(String name, String value)
	{
		UserProp prop = new UserProp();
		prop.setUserId(getId());
		prop.setPropName(name);
		prop.setPropValue(value);
		properties.add(prop);
	}

	public String getProperty(String name)
	{
		Iterator it = properties.iterator();
		while (it.hasNext())
		{
			UserProp prop = (UserProp) it.next();
			if (prop.getPropName().equalsIgnoreCase(name))
			{
				return prop.getPropValue();
			}
		}
		return "";

	}

	public void setProperties(Set properties)
	{
		this.properties = properties;
	}

	public String toString()
	{
		return new ToStringBuilder(this).append("id", getId()).toString();
	}

	public String getUserEmail()
	{
		return userEmail;
	}

	public void setUserEmail(String userEmail)
	{
		this.userEmail = userEmail;
	}
}
